﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Clipper.BLL.DataBaseBLL
{
    public class StandardCurveData
    {
        static DAL.StandardCurveData dal = new DAL.StandardCurveData();

        /// <summary>
        /// 插入一个对象
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool insertStandardCurveModel(Model.DataBaseModel.StandardCurveData model)
        {
            return dal.insertData(model);
        }


        /// <summary>
        /// 检查是否存在这条信息
        /// </summary>
        /// <returns></returns>
        public bool CheckExist(string detectItem)
        {
            return dal.Exists(detectItem);
        }

        /// <summary>
        /// 根据名字获取一个对象
        /// </summary>
        /// <param name="detectItemName"></param>
        /// <returns></returns>
        public Model.DataBaseModel.StandardCurveData GetModel(string detectItemName)
        {
            return dal.getModel(detectItemName);
        }

        /// <summary>
        /// 获取整个集合中的检测项
        /// </summary>
        /// <returns></returns>
        public List<Model.DataBaseModel.StandardCurveData> GetAllStandardDetectItem()
        {
            DataSet ds = dal.seletAll("");

            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.DataBaseModel.StandardCurveData> DataTableToList(DataTable dt)
        {
            List<Model.DataBaseModel.StandardCurveData> modelList = new List<Model.DataBaseModel.StandardCurveData>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Clipper.Model.DataBaseModel.StandardCurveData model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModelOne(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
        /// <summary>
        /// 更新标准曲线的数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool updateStandardCurveData(Model.DataBaseModel.StandardCurveData model)
        {
            return dal.update(model);
        }


        public bool upadateCloseDateAndNum(Model.DataBaseModel.StandardCurveData model)
        {
            return dal.updateDateAndNum(model);
        }
    }
}
